{% extends 'main_hub/base.html' %}

{% block title %}
    番剧
{% endblock %}

{% block content %}
    <div class="container">
        {#    类型选择#}
        <div class="row">
            <div class="col-auto">
                <nav class="nav nav-pills">
                    <a href="{% url 'cartoon' %}?city={{ city }}&order={{ order }}&page_name=fan"
                       class="nav-link {% ifequal category None %}active{% endifequal %}">
                        全部
                    </a>
                    {% for type in video_type %}
                        {% ifnotequal type.0 '15' %}
                            <a href="{% url 'cartoon' %}?ct={{ forloop.counter }}&city={{ city }}&order={{ order }}&page_name=fan"
                               class="nav-link {% ifequal category forloop.counter %}active{% endifequal %}">
                                <span>{{ type.1 }}</span>
                            </a>
                        {% endifnotequal %}
                    {% endfor %}
                </nav>
            </div>
        </div>
        <p></p>
        {#    国家选择#}
        <div class="row">
            <div class="col-auto">
                <nav class="nav nav-pills">
                    <a href="{% url 'cartoon' %}?ct={{ category }}&order={{ order }}&page_name=fan"
                       class="nav-link {% ifequal city None %}active{% endifequal %}">
                        <span>全部</span>
                    </a>
                    {% for type in city_type %}
                        <a href="{% url 'cartoon' %}?ct={{ category }}&city={{ forloop.counter }}&order={{ order }}&page_name=fan"
                           class="nav-link {% ifequal city forloop.counter %}active{% endifequal %}">
                            <span>{{ type.1 }}</span>
                        </a>
                    {% endfor %}
                </nav>
            </div>
        </div>
        <br>
        {#        排序方式#}
        <div class="row">
            <div class="col-auto">
                <nav class="nav nav-pills">
                {% if order %}
                {% endif %}
                    <a class="nav-link {% if not order %}active{% endif %}"
                       href="{% url 'cartoon' %}?ct={{ category }}&city={{ forloop.counter }}&page_name=fan">排序</a>
                    <a class="nav-link {% ifequal order "hot" %}active{% endifequal %}"
                       href="{% url 'cartoon' %}?ct={{ category }}&city={{ forloop.counter }}&order=hot&page_name=fan">按热度</a>
                    <a class="nav-link {% ifequal order "time" %}active{% endifequal %}"
                       href="{% url 'cartoon' %}?ct={{ category }}&city={{ forloop.counter }}&order=time&page_name=fan">按时间</a>
                </nav>
            </div>
        </div>

        <hr>
        {#    视频列表#}
        <div class="row">
            {% for video in all_video.object_list %}
                <div style="margin: 10px">
                    <div class="card" style="width:12rem;">
                        <a href="{% url 'video_detail' video.id %}?video_sub_number=1">
                            <img class="card-img-top" src="{{ MEDIA_URL }}{{ video.image }}" style="width: 12rem">
                        </a>
                        <div class="card-body">
                            <h5 class="card-title info">
                                <a href="{% url 'video_detail' video.id %}?video_sub_number=1"
                                   style="text-decoration:none;color:black;font-size: 15px;font-weight: bold">
                                    {% if video.name|length > 8 %}
                                        {{ video.name|slice:'0:8' }}...
                                    {% else %}
                                        {{ video.name }}
                                    {% endif %}</a>
                            </h5>
                            <p class="card-text">
                                {% if video.info|length > 9 %}
                                    {{ video.info|slice:'0:8' }}...
                                {% else %}
                                    {{ video.info }}
                                {% endif %}</p>
                        </div>
                    </div>
                </div>
            {% endfor %}
        </div>
        {#    分页#}
        <div class="row justify-content-center">
            <div class="col-auto" style="margin-top: 50px">
                <nav aria-label="Page navigation example">
                    <ul class="pagination" style="right:500px">
                        {% if all_video.has_previous %}
                            <li class="page-item">
                                <a href="?{{ all_video.previous_page_number.querystring }}"
                                   class="page-link" aria-label="Previous">
                                    上一页
                                </a>
                            </li>
                        {% endif %}
                        {% for page in all_video.pages %}
                            {% if page %}
                                {% ifequal page all_video.number %}
                                    <li class="page-item">
                                        <a class="page-link" href="?{{ page.querystring }}">{{ page }}</a>
                                    </li>
                                {% else %}
                                    <li>
                                        <a class="page-link page" href="?{{ page.querystring }}">{{ page }}</a>
                                    </li>
                                {% endifequal %}
                            {% else %}
                                <li class="none">...</li>
                            {% endif %}
                        {% endfor %}
                        {% if all_video.has_next %}
                            <li class="page-item">
                                <a href="?{{ all_video.next_page_number.querystring }}" class="page-link"
                                   aria-label="Next">下一页</a>
                            </li>
                        {% endif %}
                    </ul>
                </nav>
            </div>
        </div>
    </div>
{% endblock %}